class Item < ActiveRecord::Base
  has_and_belongs_to_many :effects
  has_and_belongs_to_many :properties
  belongs_to :group
  belongs_to :marketgroup
  has_one :blueprint
  has_many :materials
  has_one :price
  
  def self.search(query)
    self.find_all([ 'LOWER(name) LIKE ?', '%' + query.downcase + '%' ])
  end
  
  def self.search_blueprint(query)
    self.find_all([ "LOWER(name) LIKE ? and LOWER(name) LIKE '%blueprint%'", '%' + query.downcase + '%' ])
  end
end
